import React,{useState} from 'react'
// 关注父组件的变化
import { connect } from 'react-redux'
function Test0101(props) { 
    
    const add = (params) => {
        const anction ={type:"add",payload:2}
        props.dispatch(anction)
    }
    const sup = (params) => {
        const anction ={type:"sup",payload:2}
        props.dispatch(anction)
    }
    // 默认有的
    return (
        <div>
            {props.count} 我是chp03 <br />
            <button onClick={add}>+++2</button>
            <button onClick={sup} >---2</button>
            <button>不变</button>
        </div>
    )
}
// 父组件传给子组件,props,数据,方法函数
// const mapStateToProps = (state) =>({...state})  
const mapStateToProps = (state) =>({
    count:state.count
})        
// const mapDispatchToProps = (dispatch) => {
//     return{
//         add : () => {
//             const anction ={type:"add",payload:2}
//             dispatch(anction)
//         },
//         sup : () => {
//             const anction ={type:"sup",payload:2}
//             dispatch(anction)
//         }
//     }
// }

// const mapDispatchToProps = {
    
// }
// 函数 转化state,dispatch
export default connect(mapStateToProps,null)(Test0101)
